package com.tanhua.manager.controller;

import com.tanhua.manager.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/manage")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 用户管理-用户分页列表
     * GET /manage/users
     */
    @GetMapping("/users")
    public ResponseEntity findUserList(@RequestParam(defaultValue = "1")int page,
                                        @RequestParam(defaultValue = "10")int pagesize){
        return userService.findUserList(page,pagesize);
    }
    /**
     * 用户管理-查看用户详情
     * GET /manage/users/:userID
     */
    @GetMapping("/users/{id}")
    public ResponseEntity findUserById(@PathVariable("id") Long userId){
        return userService.findUserById(userId);
    }
    /**
     * 用户管理-查询用户发布的所有动态
     * GET /manage/messages
     */
    @GetMapping("/messages")
    public  ResponseEntity findPublishList(@RequestParam(defaultValue = "1")int page,
                                            @RequestParam(defaultValue = "10")int pagesize,
                                           @RequestParam(required = false) Long uid,
                                           @RequestParam(required = false) String state){
        return  userService.findPublishList(page,pagesize,uid,state);
    }
    /**
     * 动态管理-查看单条动态详情
     * GET /manage/messages/:id
     */
    @GetMapping("/messages/{id}")
    public  ResponseEntity findPublishById(@PathVariable("id")String publishId){
        return userService.findPublishById(publishId);
    }

/**
 * 评论列表
 * GET /manage/messages/comments
 */
@GetMapping("/messages/comments")
    public ResponseEntity findCommentList(@RequestParam(defaultValue = "1")int page,
                                           @RequestParam(defaultValue = "10")int pagesize,
                                          String messageID
                                        ){
    return userService.findCommentList(page,pagesize,messageID);
}
/**
 * 用户管理-分页查看用户的视频列表
 * GET /manage/videos
 */
@GetMapping("/videos")
    public ResponseEntity findVideoList(@RequestParam(defaultValue = "1")int page,
                                         @RequestParam(defaultValue = "10")int pagesize,
                                         Long uid){
    return userService.findVideoList(page,pagesize,uid);
}
}
